package com.codingxyz.simple.threadDemo;

import org.junit.platform.commons.function.Try;

import java.util.concurrent.*;

public class ThreadPoolDemo {

    public static void main(String[] args) {

        Executor threadPool = new ThreadPoolExecutor(
                2,
                5,
                1L,
                TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(3),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.DiscardPolicy()
        );

        try {

            for (int i = 1; i <=10 ; i++) {

                threadPool.execute(()-> {
                    System.out.println(Thread.currentThread().getName() + "\t 办理业务");
                });
            }

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
